<template>
  <nav-bar>
    <template v-slot:left>
      <div class="back" @click="returnHome">
        <img src="~assets/img/common/back.svg" alt="">
      </div>
    </template>
    <template v-slot:center>
      <div class="title">
        <div
          v-for="(item, index) in titles"
          :key="index"
          class="title-item"
          :class="{active:index === currentIndex}"
          @click="switchTab(index)"
        >
          {{ item }}
        </div>
      </div>
    </template>
  </nav-bar>
</template>

<script>
import NavBar from 'components/common/navbar/NavBar.vue';
export default {
name: 'detallHome',
  components: {
    NavBar,
  },
  props: {
  },
  data() {
    return {
      titles:['商品','参数','评论','推荐'],
      currentIndex: 0,
    };
  },
  watch: {},
  computed: {},
  methods: {
    switchTab(data){
      this.currentIndex = data;
      this.$emit('currentIndex',data);
    },
    returnHome(){
      this.$router.back()
    }
  },
  created() {},
  mounted() {}
};
</script>
<style lang="less" scoped>
.back{
  margin-top: .4rem;
}
.title {
  display: flex;
  .title-item {
    flex: 1;
  }
  .active{
    color: var(--color-high-text);
  }
}
</style>